<?php
include_once ("../Login/databaseconnection.php");
$q=$_GET["q"];
$hint="";
$name=explode(",",$q);
$type=$name[0];
$resultr= mysql_query("SELECT * FROM resource Where Resource_Type='$type'");
if($row = mysql_fetch_array($resultr))
{
$Resource_Id=$row['Resource_Id'];
}
$hint=$hint.'<select name="Serial_Number" id="Serial_Number">';
   if(isset($_POST['SaveChanges']))
	  {
	  $Serial_Number=$_SESSION['Se_Number'];	   
	   unset($_SESSION['Se_Number']);
	  }
	  if($Serial_Number!="")
	  {
	   	 $hint=$hint.'<option value="'.$Serial_Number.'">'.$Serial_Number.'</option>';
	  }
	    else
	  {
	  $hint=$hint.'<option value="Select One">Select One</option>';
	  }
		 if($Resource_Id!="")
	  {
	  $res=mysql_query("SELECT DISTINCT(Serial_Number) FROM resource_details WHERE Resource_Id='$Resource_Id'");
	  }
	  if($Resource_Id=="")
	  {
	  $res=mysql_query("SELECT DISTINCT(Serial_Number) FROM resource_details");
	  }
	   while($row=mysql_fetch_array($res))
  {
	  $Ser_Number=$row['Serial_Number'];
	  if($Serial_Number!=$Ser_Number)
	  {
	 $hint=$hint.'<option value="'.$Ser_Number.'">'.$Ser_Number.'</option>';
	  }
  }
      $hint=$hint.'</select>';
  if($hint=="")
{
$response=$response.'<select name="Serial_Number" id="Serial_Number">';
$response=$response.'<option value="Select One">Select One</option>';
$res=mysql_query("SELECT DISTINCT(Serial_Number) FROM resource_details");
	
	   while($row=mysql_fetch_array($res))
  { 
  $Ser_Number=$row['Serial_Number'];
  	 $response=$response.'<option value="'.$Ser_Number.'">'.$Ser_Number.'</option>';
  }
$response=$response.'</select>';
}
else
{
$response=$hint;
}
echo $response;
?>